package com.victor.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.victor.dao.RegisteruserDao;
import com.victor.entity.User;
import com.victor.entity.UserAddKey;
import com.victor.service.RegisteruserService;

@Service
public class RegisteruserServiceImpl implements RegisteruserService {

	@Autowired
	private RegisteruserDao dao;

	// 获取注册用户列表（flag传0是查询正常列表 1是查询已冻结列表）注册时间筛选（选择时间）
	@Override
	public List<User> getRegisterusers(String frozen, String ruStarttime, String ruEndtime) {
		return dao.getUsers(frozen, ruStarttime, ruEndtime);
	}

	// 批量冻结
	@Override
	public boolean batchFrozen(int[] userids, String frozen_cycle, String frozen_starttime, String frozen_endtime,
			String frozen_title, String frozen_details) {
		return dao.batchFrozen(userids, frozen_cycle, frozen_starttime, frozen_endtime, frozen_title,
				frozen_details) > 0 ? true : false;
	}

	// 用户详情
	@Override
	public User getUserByid(Integer userid) {
		return dao.getUserByid(userid);
	}

	//通过传入的userids查询需要发送短信的用户列表
	@Override
	public List<User> getUserByUserids(int[] userids) {
		return dao.getUserByUserids(userids);
	}

	// 添加操作日志
//	@Override
//	public boolean addUserLog(UserLog userLog) {
//		return dao.addUserLog(userLog);
//	}

//	获取操作日志列表
//	@Override
//	public List<UserLog> getAllUserLog(String ulStarttime, String ulEndtime) {
//		return dao.getAllUserLog(ulStarttime, ulEndtime);
//	}
	
	@Override
	public int addKey(String key_name, String key_meaning) {
		// 添加字段
		dao.addKey(key_name);
		// 添加字段字典
		int j = dao.addUserAddKey(key_name, key_meaning);
		return j;
	}
	
	@Override
	public int delKey(String key_name) {
		// 删除字段
		dao.delKey(key_name);
		
		// 删除字段字典
		int j = dao.delUserAddKey(key_name);
		return j;
	}

	@Override
	public List<UserAddKey> getUserAddKey() {
		return dao.getUserAddKey();
	}

	@Override
	public Map<String, Object> getUserAddByuserid(Integer userid) {
		return dao.getUserAddByuserid(userid);
	}
}
